<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../lib/vue.js"></script>
    <style>
        #overlay {
            background: rgba(0, 0, 0, 0.6);
            width:100%;
            margin:auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }
        #center {
            background: rgb(255, 254, 254);
            border-radius: 5px;
            padding-top: 15px;
            padding-left: 30px;
            padding-bottom: 15px;
            width: 290px;
            height: 160px;
            position: fixed;
            margin:auto
        }
    </style>
</head>
<body>
    <div id="box">
        <button @click="isShow=true">show</button>
        <!-- 第二种方法，可以加click.self，不用阻止冒泡，只有时间源是自己的时候才会触发 -->
        <div id="overlay" v-show="isShow" @click.self="isShow=false">
            <div id="center" @click.stop> <!-- 第一种方法：点周边一圈消失，点center这里会阻止冒泡，框不消失 -->
                <div>用户名<input type="text"></div>
                <div>密码<input type="password"></div>
                <div><button>登录</button></div>
            </div>
        </div>
    </div>
    
    <script>
        var vm = new Vue({
            el: "#box",
            data: {
                isShow: false
            }
        })
    </script>
</body>
</html>